package com.guigu.qingcheng.orderservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.qingcheng.orderservice.mapper.TbReturnOrderItemMapper;
import com.guigu.qingcheng.orderservice.service.TbReturnOrderItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.qingcheng.pojo.order.TbReturnOrderItem;
import com.guigu.qingcheng.utils.R;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2020-07-08
 */
@Service
public class TbReturnOrderItemServiceImpl extends ServiceImpl<TbReturnOrderItemMapper, TbReturnOrderItem> implements TbReturnOrderItemService {

    @Override
    public R findPage(Integer page, Integer size, Map<String, Object> searchMap) {
        Page<TbReturnOrderItem> tbReturnOrderItemPage = new Page<>(page,size);

        QueryWrapper<TbReturnOrderItem> wrapper = new QueryWrapper<>();
        if (searchMap != null) {
            if (searchMap.get("id") != null && !"".equals(searchMap.get("id")))
                wrapper.eq("id",searchMap.get("id"));
            if (searchMap.get("name") != null && !"".equals(searchMap.get("name")))
                wrapper.like("name",searchMap.get("name"));
        }
        baseMapper.selectPage(tbReturnOrderItemPage,wrapper);
        return R.ok().data("total",tbReturnOrderItemPage.getTotal()).data("rows",tbReturnOrderItemPage.getRecords());
    }

}
